package com.cskt.itripbiz.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        //允许所有的请求路径
        registry.addMapping("/**")
                //允许所有来源
                .allowedOrigins("*")
                //允许所有类型的方法
                .allowedMethods("GET", "POST", "DELETE", "PUT", "HEAD",
                        "OPTIONS")
                //配置超时
                .maxAge(3600)
                //允许所有请求头
                .allowedHeaders("*");
    }
}
